package com.smh.ZongHeLianXi;

import java.util.Arrays;

public class Test {
    public static void main(String[] args) {

        GirlFriend girlFriend = new GirlFriend("asd",18,175);
        GirlFriend girlFriend1 = new GirlFriend("zxc",18,170);
        GirlFriend girlFriend2 = new GirlFriend("zza",19,171);
        GirlFriend girlFriend3 = new GirlFriend("zxx",19,171);

        GirlFriend[] arr = {girlFriend,girlFriend1,girlFriend2,girlFriend3};

        Arrays.sort(arr,(o1,o2)->{
            double temp = o1.getAge()-o2.getAge();
            if (temp==0){
                temp = (o1.getHeight()-o2.getHeight());
            }
            if (temp==0){
                temp = o1.getName().compareTo(o2.getName());
            }
            if (temp>0){
                return 1;
            }else if (temp<0){
                return -1;
            }else {
                return 0;
            }
        });

        System.out.println(Arrays.toString(arr));

    }
}
class GirlFriend{
    private String name;
    private int age;
    private double height;//身高

    public GirlFriend() {
    }

    public GirlFriend(String name, int age, double height) {
        this.name = name;
        this.age = age;
        this.height = height;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    /**
     * 获取
     * @return height
     */
    public double getHeight() {
        return height;
    }

    /**
     * 设置
     * @param height
     */
    public void setHeight(double height) {
        this.height = height;
    }

    public String toString() {
        return "GirlFriend{name = " + name + ", age = " + age + ", height = " + height + "}";
    }
}
